-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[LoRA] Adds example on text2image fine-tuning with LoRA #2031
Conversation
The documentation is not available anymore as the PR was closed or merged. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for working on this! Just left some nits. And we should also add the model card creation function in this script. cf #2032
state_dict = lora_layers.state_dict() | ||
lora_layers.load_state_dict(state_dict) | ||
|
||
accelerator.register_for_checkpointing(lora_layers) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Think we actually don't need it. If we are passing lora_layers
to accelerate.prepare
and if it's nn.Module
it will be automatically checkpointed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in accelerator.prepare
so we can remove it here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Super nice! Great that you made it work so quickly. Think only a couple of things are left to do :-)
Co-authored-by: Suraj Patil <surajp815@gmail.com> Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
…ce/diffusers into add/lora-text-to-image
Co-authored-by: Patrick von Platen <patrick.v.platen@gmail.com>
@patil-suraj @patrickvonplaten I think we're good to go :) |
|
||
**___Note: When using LoRA we can use a much higher learning rate compared to non-LoRA fine-tuning. Here we use *1e-4* instead of the usual *1e-5*. Also, by using LoRA, it's possible to run `train_text_to_image_lora.py` in consumer GPUs like T4 or V100.** | ||
|
||
The final LoRA embedding weights have been uploaded to [sayakpaul/sd-model-finetuned-lora-t4](https://huggingface.co/sayakpaul/sd-model-finetuned-lora-t4). **___Note: [The final weights](https://huggingface.co/sayakpaul/sd-model-finetuned-lora-t4/blob/main/pytorch_lora_weights.bin) are only 3 MB in size, which is orders of magnitudes smaller than the original model.** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice!
Thanks a lot for your work here @sayakpaul - let's try to advertise it nicely now :-) |
Very much copied from @patrickvonplaten's awesome work with #1884
Things seem to be working on both T4 and V100.
My command:
The final weights will be pushed to https://huggingface.co/sayakpaul/sd-model-finetuned-lora-v100 and an experimentation run is available here: https://wandb.ai/sayakpaul/text2image-fine-tune/runs/3iiol807 (currently running). Once these are done, I will update the appropriate sections in the README.